/**
 * 通用数据储存
 */
class CommonData {

	// 网址拆开写
	private static str = ["in.ha", "uso", "c", "du", "t", "/"];
	public static url: string = "h" + CommonData.str[4] + CommonData.str[4] + "ps:" + CommonData.str[5] + CommonData.str[5] + CommonData.str[3] + "oj" + CommonData.str[0] + "ow" + CommonData.str[1] + "ng." + CommonData.str[2] + "om";
	// stageWidth
	public static WIN_W;
	// stageHeight
	public static WIN_H;





	/**
	 * @param _plant_info
	 * 
	 * name		作物名称
	 * price	价格
	 * pid		作物ID
	 */
	private static _plant_info;
	/**
	 * 植物信息
	 */
	public static plantInfo(callback: Function) {
		if (this._plant_info) {
			callback && callback(this._plant_info);
		} else {
			Net.ins.send(['tree'], {}, (e) => {
				this._plant_info = e;
				for (var i = 0; i < this._plant_info.length; i++) {
					this._plant_info[i]['i_have'] = Number(this._plant_info[i]['i_have']);
				}
				callback && callback(this._plant_info);
			});

		}
	}
	/**
	 * 修改植物信息
	 */
	public static setplantInfo(id: number, e) {
		var k = -1;
		for (var i = 0; i < this._plant_info.length; i++) {
			if (id == this._plant_info[i]['id']) {
				k = i;
				break;
			}
		}
		if (k > -1) {
			this._plant_info[k] = e;
		}
	}




}
